package com.adcc.ags.gms.user.vo;

import com.adcc.ags.gms.core.vo.BaseVO;
import com.adcc.ags.gms.user.entity.BlackList;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;

/**
 * Created by zhangpeng on 2016/8/16.
 */
public class BlackListVO extends BaseVO {

    // ID
    private long id;

    // 黑名单所属BGS用户ID
    private long gwUserId;

    // 黑名单用户名,即GWUser名
    private String name;

    // 发送地址
    private String sendAddress;

    // 接收地址
    private String recvAddress;

    // SMI
    private String smi;

    // 机尾号
    private String an;

    // 全文关键字
    private String specLable;

    // 关键字起始位
    private Integer index;

    public long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public void setGwUserId(long gwUserId) {
        this.gwUserId = gwUserId;
    }

    public long getGwUserId(){
        return gwUserId;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getSendAddress() {
        return sendAddress;
    }

    public void setSendAddress(String sendAddress) {
        this.sendAddress = sendAddress;
    }

    public String getRecvAddress() {
        return recvAddress;
    }

    public void setRecvAddress(String recvAddress) {
        this.recvAddress = recvAddress;
    }

    public String getSmi() {
        return smi;
    }

    public void setSmi(String smi) {
        this.smi = smi;
    }

    public String getAn() {
        return an;
    }

    public void setAn(String an) {
        this.an = an;
    }

    public String getSpecLable() {
        return specLable;
    }

    public void setSpecLable(String specLable) {
        this.specLable = specLable;
    }

    public Integer getIndex() {
        return index;
    }

    public void setIndex(Integer index) {
        this.index = index;
    }

    /**
     * 构造函数
     */
    public BlackListVO() {
        super();
    }

    /**
     * 构造函数
     * @param blackList
     */
    public BlackListVO(BlackList blackList) {
        if (blackList != null) {
            id = blackList.getId();
            gwUserId = blackList.getGwUserId();
            name = blackList.getName();
            sendAddress = blackList.getSendAddress();
            recvAddress = blackList.getRecvAddress();
            smi = blackList.getSmi();
            an = blackList.getAn();
            specLable = blackList.getSpecLable();
            index = blackList.getIndex();
        }
    }

    @Override
    public BlackList toEntity() {
        BlackList blackList = new BlackList();
        blackList.setId(this.id);
        blackList.setGwUserId(this.gwUserId);
        blackList.setName(this.name);
        blackList.setSendAddress(this.sendAddress);
        blackList.setRecvAddress(this.recvAddress);
        blackList.setSmi(this.smi);
        blackList.setAn(this.an);
        blackList.setSpecLable(this.specLable);
        blackList.setIndex(this.index);
        return blackList;
    }

    @Override
    public String toJson() throws JsonProcessingException {
        return new ObjectMapper().writeValueAsString(this);
    }

}
